import axios from "./axios";

// 验证账号是否存在
export async function accountname(accountname) {
  const res = await axios.post("/index.php/login/checkloginname", {
    accountname: accountname,
  });
  return JSON.parse(res.data);
}
// 登录
export async function login(account, pwd) {
  const res = await axios.post("/index.php/login/checkaccount", {
    account: account,
    pwd: pwd,
  });
  return JSON.parse(res.data);
}
// 更新密码
export async function confirmpwd(newpwd, confirmpwd, id) {
  const res = await axios.post("/index.php/login/modifypwd", {
    newpwd: newpwd,
    confirmpwd: confirmpwd,
    id: id,
  });
  return JSON.parse(res.data);
}
// 侧边栏
export async function getrolelist() {
  const res = await axios.post("/index.php/admin/getrolelist");
  return JSON.parse(res.data);
}
// 登录账号列表
export async function adminList(account, phone, count) {
  const res = await axios.post("/index.php/admin/getlist", {
    account: account,
    phone: phone,
    count: count,
  });
  return JSON.parse(res.data);
}
// 添加管理员账号
export async function addadminFun(account, pwd, phone, role) {
  const res = await axios.post("/index.php/admin/addadmin", {
    account: account,
    pwd: pwd,
    phone: phone,
    role: role,
  });
  return JSON.parse(res.data);
}
//  获取用户信息列表 page必传
export async function getUserlist(
  userphone,
  wxname,
  starttime,
  endtime,
  status,

  count,
  page
) {
  const res = await axios.post("/index.php/user/getuserlist", {
    userphone: userphone,
    wxname: wxname,
    starttime: starttime,
    endtime: endtime,
    status: status,
    count: count,
    page: page,
  });
  return JSON.parse(res.data);
}
//  订单列表   count page必传
export async function getorderlist(
  consignee,
  phone,
  ordernum,
  status,
  pay,
  age,
  starttime,
  endtime,
  count,
  page
) {
  const res = await axios.post("/index.php/order/getorderlist", {
    consignee: consignee,
    phone: phone,
    ordernum: ordernum,
    status: status,
    pay: pay,
    age: age,
    starttime: starttime,
    endtime: endtime,
    count: count,
    page: page,
  });
  return JSON.parse(res.data);
}
// 订单详情  目前报错
export async function orderdetailsFun(oid) {
  const res = await axios.post(`/index.php/order/getorderdetails`, {
    oid: oid,
  });
  return JSON.parse(res.data);
}
// 添加订单
export async function modifyorderFun(
  logisticsno,
  orderLOgistcsType,
  state,
  remarks,
  id
) {
  const res = await axios.post("/index.php/order/modifyorder", {
    logisticsno: logisticsno,
    orderLOgistcsType: orderLOgistcsType,
    state: state,
    remarks: remarks,
    id: id,
  });

  return JSON.parse(res.data);
}
// banner列表
export async function bannerList(dispaly, state, count, page) {
  const res = await axios.post("/index.php/Advertising/getbannrlist", {
    dispaly: dispaly,
    state: state,
    count: count,
    page: page,
  });
  return JSON.parse(res.data);
}
// 新增banner
export async function addadvertisingFun(
  img,
  dispaly,
  starttime,
  endtime,
  describe,
  url,
  uid
) {
  const res = await axios.post("/index.php/Advertising/addadvertising", {
    img: img,
    dispaly: dispaly,
    starttime: starttime,
    endtime: endtime,
    describe: describe,
    url: url,
    uid: uid,
  });
  return JSON.parse(res.data);
}
// 图片上传

export async function uploadimg(imgFile) {
  const res = await axios.post("/index.php/advertising/imgupload", {
    imgFile: imgFile,
  });
  return JSON.parse(res.data);
}

// 科学育儿话题列表
export async function childrenList() {
  const res = await axios.post("/index.php/Sciencetopic/topiclist", {});
  return JSON.parse(res.data);
}

// 科学育儿文章列表
export async function ScientificArticles(
  classifyid,
  title,
  state,
  starttime,
  endtime,
  count,
  page
) {
  const res = await axios.post("/index.php/Science/sciencelist", {
    classifyid: classifyid,
    title: title,
    state: state,
    starttime: starttime,
    endtime: endtime,
    count: count,
    page: page,
  });
  return JSON.parse(res.data);
}
// 账号数据更新
export async function modifyaccountinfo(account, pwd, phone, state, id, role) {
  const res = await axios.post("/index.php/admin/modifyaccountinfo", {
    account: account,
    pwd: pwd,
    phone: phone,
    state: state,
    id: id,
    role: role,
  });
  return JSON.parse(res.data);
}
// 科学育儿主题添加
export async function ChildrenisTheme(topicname, status) {
  const res = await axios.post("/index.php/sciencetopic/addtopic", {
    topicname: topicname,
    status: status,
  });
  return JSON.parse(res.data);
}
// 科学育儿文章详情

export async function ViewDetails(id) {
  const res = await axios.post("/index.php/Science/sciencedetails", {
    id: id,
  });
  return JSON.parse(res.data);
}

//  科学育儿文章设置置顶
export async function StickyPosts(id, istop) {
  const res = await axios.post("/index.php/Science/setistop", {
    id: id,
    istop: istop,
  });
  return JSON.parse(res.data);
}

// banner详情

export async function detailsbanner(id) {
  const res = await axios.post("/index.php/Advertising/bannerdetails", {
    id: id,
  });
  return JSON.parse(res.data);
}
// 用户数据导出
export async function excelFun(uid) {
  const res = await axios.post("/index.php/user/export", {
    uid: uid,
  });
  return JSON.parse(res.data);
}

// 登录账号详情
export async function adminListidet(id) {
  const res = await axios.post("/index.php/admin/getlist", { id: id });
  return JSON.parse(res.data);
}

// 广告更新接口
export async function modifyadvertising(starttime, endtime, state, id) {
  const res = await axios.post("/index.php/Advertising/modifyadvertising", {
    starttime: starttime,
    endtime: endtime,
    state: state,
    id: id,
  });
  return JSON.parse(res.data);
}
// 科学育儿更新文章
export async function Childupdates(
  title,
  subtitle,
  coverimg,
  classifyid,
  shareimg,
  sharetitle,
  state,
  urllink,
  count,
  contentimg,
  source,
  id
) {
  const res = await axios.post("/index.php/Science/modifyscience", {
    title: title,
    subtitle: subtitle,
    coverimg: coverimg,
    classifyid: classifyid,
    shareimg: shareimg,
    sharetitle: sharetitle,
    state: state,
    urllink: urllink,
    count: count,
    contentimg: contentimg,
    source: source,
    id: id,
  });
  return JSON.parse(res.data);
}
// 科学育儿新增文章
export async function addscience(
  title,
  subtitle,
  coverimg,
  classifyid,
  type,
  shareimg,
  sharetitle,
  state,
  urllink,
  count,
  contentimg,
  source
) {
  const res = await axios.post("/index.php/Science/addscience", {
    title: title,
    subtitle: subtitle,
    coverimg: coverimg,
    classifyid: classifyid,
    type: type,
    shareimg: shareimg,
    sharetitle: sharetitle,
    state: state,
    urllink: urllink,
    count: count,
    contentimg: contentimg,
    source: source,
  });
  return JSON.parse(res.data);
}
// 获取品牌大使列表

export async function Brandambassadortask(
  copywrite,
  starttime,
  endtime,
  label,
  count,
  page
) {
  const res = await axios.post("/index.php/Brandambassadortask/getlist", {
    copywrite: copywrite,
    starttime: starttime,
    endtime: endtime,
    label: label,
    count: count,
    page: page,
  });
  return JSON.parse(res.data);
}

// 品牌大使获取标签列表

export async function fungetlablelist(username, password, name) {
  const res = await axios.post("/index.php/Brandlable/getlablelist", {
    username: username,
    password: password,
    name: name,
  });
  return JSON.parse(res.data);
}

// 品牌大使详情数据

export async function getTextDatadetails(id) {
  const res = await axios.post("/index.php/Brandambassadortask/taskdetails", {
    id: id,
  });
  return JSON.parse(res.data);
}

// 品牌大使新增标签

export async function pushLabelMethod(name) {
  const res = await axios.post("/index.php/Brandlable/addlable", {
    name: name,
  });
  return JSON.parse(res.data);
}

// 新增品牌大使任务

export async function addbrandambassadortask(
  copywrite,
  imgurl,
  url,
  title,
  coverimg,
  type,
  displayrole,
  label
) {
  const res = await axios.post(
    "/index.php/Brandambassadortask/addbrandambassadortask",
    {
      copywrite: copywrite,
      imgurl: imgurl,
      url: url,
      title: title,
      coverimg: coverimg,
      type: type,
      displayrole: displayrole,
      label: label,
    }
  );
  return JSON.parse(res.data);
}

// 更新品牌大使

export async function modifybrandambassadortask(
  copywrite,
  imgurl,
  url,
  title,
  coverimg,
  displayrole,
  label,
  state,
  id
) {
  const res = await axios.post(
    "/index.php/Brandambassadortask/modifybrandambassadortask",
    {
      copywrite: copywrite,
      imgurl: imgurl,
      url: url,
      title: title,
      coverimg: coverimg,
      displayrole: displayrole,
      label: label,
      state: state,
      id: id,
    }
  );
  return JSON.parse(res.data);
}
// 品牌大使消息推送

export async function pushmessagefun(id) {
  const res = await axios.post("/index.php/Brandambassadortask/pushmessage", {
    id: id,
  });
  return JSON.parse(res.data);
}
// 品牌大使列表
export async function getapplyFun(
  page,
  count,
  userphone,
  starttime,
  endtime,
  name,
  status
) {
  const res = await axios.post("/index.php/Applybrandambassador/getapplylist", {
    page: page,
    count: count,
    userphone: userphone,
    starttime: starttime,
    endtime: endtime,
    name: name,
    status: status,
  });
  return JSON.parse(res.data);
}
// 品牌大使审核
export async function examination(uid, brandStatus) {
  const res = await axios.post("/index.php/Applybrandambassador/examination", {
    uid: uid,
    brandStatus: brandStatus,
  });
  return JSON.parse(res.data);
}
//  社区文章发布
export async function addCommunity(title, imgurl, count, topicid, likenum, authorname, headerimg) {
  const res = await axios.post("/index.php/Community/addCommunity", {
    title, imgurl, count, topicid, likenum, authorname, headerimg
  });
  return JSON.parse(res.data);
}

// 社区文章审核

export async function articleReview(id, state) {
  const res = await axios.post("/index.php/Community/articleReview", {
    id: id,
    state: state,
  });
  return JSON.parse(res.data);
}

// 社区文章列表

export async function gettextlist(page, count, title, topicid, state, starttime, endtime, phone) {
  const res = await axios.post("/index.php/Community/getlist", {
    page, count, title, topicid, state, starttime, endtime, phone
  });
  return JSON.parse(res.data);
}

// 文章排序设置

export async function setArticleSort(id, sort) {
  const res = await axios.post("/index.php/Community/setArticleSort", {
    id: id,
    sort: sort,
  });
  return JSON.parse(res.data);
}

//  话题列表

export async function gettopiclist() {
  const res = await axios.post("/index.php/Communitytopic/topiclist", {});
  return JSON.parse(res.data);
}
export async function notedetails(id) {
  const res = await axios.post("/index.php/Community/notedetails", {
    id
  });
  return JSON.parse(res.data);
}

// 新增话题
export async function addtopic(topic, bannerimg, topiclistimg, topicdetailsimg, explain, posters) {
  const res = await axios.post("/index.php/Communitytopic/addtopic", {
    topic, bannerimg, topiclistimg, topicdetailsimg, explain, posters
  });
  return JSON.parse(res.data);
}

// 取消置顶
export async function cancelArticleSort(id) {
  const res = await axios.post("/index.php/Community/cancelArticleSort", {
    id
  });
  return JSON.parse(res.data);
}

// 话题文章列表
export async function topicArticlelist(id, count, page) {
  const res = await axios.post("/index.php/Communitytopic/gettopicArticlelist", {
    id, count, page
  });
  return JSON.parse(res.data);
}
// 话题列表
export async function gettextttopiclist(title, starttime) {
  const res = await axios.post('/index.php/Communitytopic/topiclist',{
    title,starttime
  });
  return JSON.parse(res.data);
}
// 话题设置置顶

export async function funsettopicSTop(id) {
  const res = await axios.post("/index.php/Communitytopic/settopicSTop", {
    id
  });
  return JSON.parse(res.data);
}
// 话题取消设置置顶

export async function funcanceltopicTop(id) {
  const res = await axios.post("/index.php/Communitytopic/canceltopicTop", {
    id
  });
  return JSON.parse(res.data);
}
// 话题更新 

export async function funtopicReview(id, topic, bannerimg, topiclistimg, topicdetailsimg, explain, posters, state) {
  const res = await axios.post("/index.php/Communitytopic/topicReview", {
    id, topic, bannerimg, topiclistimg, topicdetailsimg, explain, posters, state
  });
  return JSON.parse(res.data);
}